#ifndef COLLECTION_LIST_H
#define COLLECTION_LIST_H

#include "Collection.h"

typedef std::list<Item*> Item_List;

class Collection_List : public Collection {
public:
    // Constructor and destructor:
    Collection_List();
    ~Collection_List();

    // Modifiers:
    void append(Item *item);
    void partition(Categorizer& cat, vector<Collection*> parts);
    void append(Collection& other);
    void clear();
    int size();

    // Iterator handling:
    virtual iterator begin() = 0;
    virtual iterator end() = 0;

    // Count of items in this collection.
    int n;

private:
    // Peculiar to a list: lets you re-splice parts of a list.
    void move_block(Collection& source, Collection& destination);

    // Peculiar to a list: lets you build a subset using a range
    // within a list
    Collection_List(Item_List superset,
                    iterator first,
                    iterator last,
                    int n);

    // the data in question (a list of labeled metric objs)
    Item_List items;

    // used for iteration.
    Item_List::iterator first;
    // need ptr to last entry, 'cause the list.end() points beyond it.
    // otherwise splicing can't be done.
    Item_List::iterator last;
};

class Collection_List_Iterator : public Collection_Iterator {
private:
    Collection_List &collection;
    Item_List::iterator iter;

    Collection_List_Iterator(Collection_List& col, int index);

public:
    Item& operator*();
    iterator operator++();
    iterator operator++(int);
};

#endif
